package com.icinfo.cloud.provider.punish.fastcase.controller;

import com.icinfo.cloud.provider.common.constant.Constant;
import com.icinfo.cloud.provider.punish.fastcase.dto.FastCaseEvidenceCollectInfoDeleteDto;
import com.icinfo.cloud.provider.punish.fastcase.dto.FastCaseEvidenceCollectInfoSaveDto;
import com.icinfo.cloud.provider.punish.fastcase.dto.FastCaseFormSubmitAddInfoDto;
import com.icinfo.cloud.provider.punish.fastcase.service.IFastCaseFormSubmitService;
import com.icinfo.cloud.provider.punish.fastcase.vo.FastCaseEvidenceCollectInfoVo;
import com.icinfo.cloud.provider.punish.fastcase.vo.FastCaseFormSubmitAddInfoVo;
import com.icinfo.cloud.provider.punish.ucase.punishinform.dto.FastCaseAddInfoDto;
import com.icinfo.cloud.provider.punish.ucase.punishinform.dto.FastCaseAddInfoTemporaryDto;
import com.icinfo.framework.common.web.Result;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 描述：简案快办表单提交 控制器
 * @author shishengyao
 * @description
 * @date 2023/8/16
 */
@RestController
@RequestMapping("/punish/fast/case/formSubmit")
public class FastCaseFormSubmitController {
    @Resource
    private IFastCaseFormSubmitService fastCaseEvidenceCollectService;
    /**
     * 【V1.12.1】描述：获取证据采集列表
     *
     * @param
     * @return
     */
    @GetMapping("/getEvidenceCollectInfo")
    public Result<FastCaseEvidenceCollectInfoVo> getEvidenceCollectInfo(@RequestParam(value = "caseId") String caseId){
        FastCaseEvidenceCollectInfoVo result =  fastCaseEvidenceCollectService.getEvidenceCollectInfo(caseId);
        return Result.success(result);
    }

    /**
     * 【V1.12.1】描述：保存证据采集信息
     *
     * @param saveDto 保存dto
     * @return {@link Result<String> }
     * @author shishengyao
     * @date 2023/08/24
     */
    @PostMapping("/saveEvidenceCollectInfo")
    public Result<String> saveEvidenceCollectInfo( @RequestBody FastCaseEvidenceCollectInfoSaveDto saveDto){
        int num=0;
        if (Constant.STRING_1.equals(saveDto.getOperateType())){
            num=fastCaseEvidenceCollectService.saveEvidenceCollectInfo(saveDto);
        }else {
            num=fastCaseEvidenceCollectService.saveEvidenceCollectInfoTemporary(saveDto);
        }
        if(num>0){
            return Result.success("保存成功");
        }
        return Result.error("保存失败");
    }

    /**
     * 【V1.12.1】简案快办调查终结保存
     *
     * @param fastCaseAddInfoDto
     * @return {@link Result<String> }
     * @author shishengyao
     * @date 2023/08/24
     */
    @PostMapping(value = "/saveInvestigateEnd")
    public Result<String> saveInvestigateEnd(@RequestBody @Validated FastCaseFormSubmitAddInfoDto fastCaseAddInfoDto){
        int num=0;
        if (Constant.STRING_1.equals(fastCaseAddInfoDto.getOperateType())){
             num=fastCaseEvidenceCollectService.saveInvestigateEnd(fastCaseAddInfoDto);
        }else {
             num=fastCaseEvidenceCollectService.saveInvestigateEndTemporary(fastCaseAddInfoDto);
        }
        if(num>0){
            return Result.success("保存成功");
        }
        return Result.error("保存失败");
    }

    /**
     * 【V1.12.1】 简案快办调查终结暂存信息获取
     *
     * @param dto
     * @return {@link Result<FastCaseAddInfoDto> }
     * @author shishengyao
     * @date 2023/08/24
     */
    @PostMapping(value = "/getInvestigateEndTemporary")
    public Result<FastCaseFormSubmitAddInfoVo> getInvestigateEndTemporary(@RequestBody @Validated FastCaseAddInfoTemporaryDto dto){
        FastCaseFormSubmitAddInfoVo fastCaseAddInfoDto=fastCaseEvidenceCollectService.getFastCaseAddInfoTemporary(dto);
        return Result.success("获取成功",fastCaseAddInfoDto);
    }

    /**
     * 【V1.12.1】删除证据采集信息
     *
     * @param dto
     * @return {@link Result<String> }
     * @author shishengyao
     * @date 2023/09/06
     */
    @PostMapping(value = "/delEvidenceCollectInfo")
    public Result<String> delEvidenceCollectInfo(@RequestBody @Validated FastCaseEvidenceCollectInfoDeleteDto dto){
        Boolean flag=fastCaseEvidenceCollectService.delEvidenceCollectInfo(dto);
        if(flag){
            return Result.success("保存成功");
        }
        return Result.error("保存失败");
    }
}
